/*
 * LCTServerImpl.java
 *
 * Created on October 18, 2007, 1:07 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.lct.eq2.rmi;

import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.ExportException;
import java.rmi.server.UnicastRemoteObject;

/**
 *
 * @author waitek
 */
public class LCTServer {
    
    /** Creates a new instance of LCTServerImpl */
    public LCTServer() throws RemoteException {
    }
    
    /**
     * Starts an internal RMI registry.
     *@throws ExportException, RemoteException
     */
    private static boolean startRMIRegistry() throws ExportException, RemoteException {
        boolean rval;
        try {
            LocateRegistry.createRegistry(1099);
            rval = true;
        } catch (Exception e) {
            rval = false;
        }
        return rval;
    }
    
    public static void main(String args[]) {
            try {
            if (startRMIRegistry())
                System.out.println("Internal RMI Registry started.");
            else
                System.out.println("RMI Registry already running on this port.");
              
            LCTRemoteImpl lctRemote = new LCTRemoteImpl();
            Naming.rebind("LCTRemoteServer", lctRemote);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
}
